﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using EMC.Service.Biz;
namespace EMC.Service.Web
{
    /// <summary>
    /// Authorization 的摘要说明
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    // 若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务，请取消对下行的注释。
    // [System.Web.Script.Services.ScriptService]
    public class Authorization : System.Web.Services.WebService
    {

        [WebMethod]
        public ResponseObject<string> NewAccount(string Account, string Password)
        {
            Biz.Common.AuthorizationBiz authbiz = new Biz.Common.AuthorizationBiz();
            authbiz.NewAccount(Account, Password);
            var dic = new ResponseObject<string>();
            if (!authbiz.IsOk)
            {
                dic.ResponesInfo = new ResponseInfo() { InfoCode = authbiz.InfoCode, InfoMsg = authbiz.InfoMsg };
                dic.Data = "string";
                return dic;
            }
            else
            {
                dic.ResponesInfo = new ResponseInfo() { InfoCode = "Success", InfoMsg = "创建成功" };
                dic.Data = "创建账户";
                return dic;
            }
        }

        [WebMethod]
        public ResponseObject<EMC.Service.DAL.Common_Account> ValidateAccount(string Account, string Password)
        {
            Biz.Common.AuthorizationBiz authbiz = new Biz.Common.AuthorizationBiz();
            var acct=  authbiz.ValidateAccount(Account, Password);
            var dic = new ResponseObject<EMC.Service.DAL.Common_Account>();
            if (!authbiz.IsOk)
            {
                dic.ResponesInfo = new ResponseInfo() { InfoCode = authbiz.InfoCode, InfoMsg = authbiz.InfoMsg };
                dic.Data =new DAL.Common_Account ();
                return dic;
            }
            else
            {
                dic.ResponesInfo = new ResponseInfo() { InfoCode = "Success", InfoMsg ="登录成功" };
                dic.Data =acct;
                return dic;
            }
            
        }
    }
}
